package com.didispace;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.annotation.Transformer;
import org.springframework.messaging.handler.annotation.Payload;

import java.text.SimpleDateFormat;
import java.util.Date;

// Spring Integration 原生支持  p360
// @EnableBinding(value = {Sink.class})
public class SinkReceiver {

    private static Logger logger = LoggerFactory.getLogger(HelloApplication.class);

    // @ServiceActivator(inputChannel=Sink.INPUT)
    // public void receive(@Payload Date payload) {
    //     logger.info("Received: " + payload);
    //     logger.info("Received: " + transform(payload));
    // }
    //
    // // 还可以通过 @Transformer 注解对指定通道的消息进行转换  p361
    // @Transformer(inputChannel = Sink.INPUT, outputChannel = Sink.INPUT)
    // public Object transform(Date message) {
    //     return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(message);
    // }

}
